<?php
    include_once './config.php';
    $user = checkLogin();
    if($_GET['date']){
        $date = $_GET['date'];
    } else {
        $date = date("Y-m-d",time());
    }
    $date_start = strtotime($date." 00:00:00");
    $date_end = strtotime($date." 23:59:59");
    $query = "select a.*,count(*) as num,user.username,user.phone from whw_order a inner join whw_user user on a.user_id = user.id where status < 2 and a.createtime BETWEEN ".$date_start. " and ".$date_end." group by a.user_id order by a.id desc";
    $rows = $objDBCD14->query($query);
    $list = [];
    if ($rows->num_rows) {
        foreach ($rows as $key => $value) {
            $list[] =  $value; 
        }  
    }
?>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>未处理订单/补助</title>
    <!-- 引入 layui.css -->
    <link rel="stylesheet" href="./layui/css/layui.css">
    <style>
        body{
           background: #f8f8f8; 
           height: 100%;
        }
        .container{
            margin: 0;
        }
        header{
            display: flex;
            align-items: center;
            background: #e64340;
            padding: 12px;
            color: #fff;
            justify-content: space-between;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 44px;
            box-sizing: border-box;
        }
        header .title{
            text-align: center;
        }
        header .layui-icon{
            font-size: 18px;
        }
        main{
            padding: 44px 0 0;
        }
        .list{
            padding: 10px;
        }
        .list .item{
            background: #fff;
            padding: 15px;
            border-radius: 5px;
            margin: 10px 0;
            display: block;
        }
        .list .item .username{
            font-size: 16px;
        }
        .list .item .username span{
          display: inline-block;
          margin-right: 10px;
        }
    </style>
</head>
<body ontouchstart>
    <div class="container" id="container">
        <header>
            <div>
                <i class="layui-icon layui-icon-left" onclick="history.back()"></i>
            </div>
            <div class="title">未处理订单/补助</div>
            <div></div>
        </header>
        <main>
            <?php if(count($list)) { ?>
                <div class="list">
                    <?php for($i = 0;$i < count($list);$i++) { ?>
                        <a class="item" href="./index.php?user_id=<?=$list[$i]['user_id']?>&date=<?=$list[$i]['date']?>">
                            <div style="display:flex;justify-content:space-between;align-items:center">
                                <div class="username">
                                   <span><?= $list[$i]['username'] ?></span>
                                   <span><?= $list[$i]['phone'] ?></span>
                                </div>
                                <div style="color: green">
                                    <?= $list[$i]['num'] ?>个订单
                                </div>
                            </div>
                        </a>
                    <?php } ?>
                </div>
            <?php } else { ?>
            <img src="./images/data-empty.png" style="width: 200px;height:auto;display:block;margin: 30vh auto" />
            <?php } ?>
        </main>
    </div>
    <!-- 引入 layui.js -->
    <script src="./layui/layui.js"></script>
    <script>
        layui.use(['layer', 'form','code'], function(){
            var $ = layui.$,layer = layui.layer,form = layui.form,code = layui.code;
        });
    </script>  
</body>
</html>